<template>
  <!-- 发送查询申请页面弹出框-->
  <el-dialog title="被查询行" center :visible.sync="open" width="1024px" :close-on-click-modal="false" @close="closeFn">
    <div style="height: '200px'; margin-bottom: '20px'">
      <ht-table
        ref="dataTable"
        :showSerialNumber="false"
        :multi-select="false"
        :dictMap="dictMap"
        :reqConfig="reqConfig"
        :initData="false"
        :randomRowKey="true"
        :canHideColumns="false"
        :canHideSearch="false"
        :canRefresh="false"
        :queryParams="queryParams"
        :tableBindColumns="tableBindColumns"
        :opButtonList="opButtonList"
        style="height: 100%"
      >
        <template v-slot:singSelect="slotProps">
          <el-radio-group v-model="temoR" @input="singleChange">
            <el-radio :label="slotProps.row.bankNo">
              <i></i>
            </el-radio>
          </el-radio-group>
        </template>
      </ht-table>
    </div>
    <el-form ref="sendForm" :model="formData" :rules="rules" label-width="126px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="查询方式：" prop="inqType">
            <el-select v-model="formData.inqType" placeholder="请选择" style="width: 224px">
              <el-option
                v-for="dict in dictMap.CLS_QUERYTYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="被查询行：" prop="inqStBrno">
            <el-input v-model="formData.inqStBrno" disabled style="width: 224px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="备注：" prop="remarks">
            <el-input type="textarea" v-model="formData.remarks" maxlength="256" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="sureApply">申请</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { applySearch, saveApply } from "@/api/cnaps/nets/queueMng/saps_queue_manage_entry.js";
import { log } from "util";
export default {
  name: "SendApply",
  components: {},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      formData: {
        inqType: "QT00",
        inqStBrno: "",
        remarks: "",
      },
      temoR: "",
      remarks: "",
      reqConfig: applySearch,
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {},
      formOptions: [],
      opButtonList: () => {
        return [];
      },
      rules: {
        inqType: [
          {
            required: true,
            message: "请选择查询方式",
            trigger: "change",
          },
        ],
        inqStBrno: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
      },
      tableBindColumns: [
        {
          label: "",
          prop: "singSelect",
          width: "50",
          sortable: false,
          customSlot: true,
        },
        {
          label: `清算行行号`,
          prop: "bankNo",
          sortable: false,
        },
        {
          label: `清算行行名`,
          prop: "bankName",
          sortable: false,
        },
      ],
    };
  },
  mounted() {},
  watch: {
    open(d) {
      if (d) {
        this.$nextTick(() => {
          this.$refs.dataTable.doQuery();
          this.temoR = "";
        });
      }
    },
  },
  methods: {
    singleChange(val) {
      console.log(val, "单选表格");
      this.formData.inqStBrno = val;
    },
    // 表单重置
    reset() {
      this.resetForm("sendForm");
      // this.$set(this, "form", {});
    },
    sureApply() {
      this.$refs["sendForm"].validate((valid) => {
        if (valid) {
          let sendData = {
            btSelectItem: "on",
            inqType: this.formData.inqType,
            inqStBrno: this.formData.inqStBrno,
            remarks: this.formData.remarks,
          };
          saveApply(sendData).then((res) => {
            console.log("发送成功！");
            this.msgSuccess("发送成功！");
            this.open = false;
            this.$emit("editComplete", true);
          });
        }
      });
    },
    // 关闭回掉
    // handleClose(done) {
    //   this.$confirm("确认关闭？")
    //     .then(_ => {
    //       this.reset();
    //       done();
    //     })
    //     .catch(_ => {});
    // },
    closeFn() {
      this.reset();
      this.open = false;
    },
    show() {
      this.open = true;
    },
  },
};
</script>
